package com.zcx.presenter;

import com.zcx.base.BaseModel;
import com.zcx.bean.PayBean;
import com.zcx.bean.WxPayBean;
import com.zcx.model.PayModel;
import com.zcx.view.AlipayView;

/**
 * @author：zcx
 * @date:on 2018/3/6 0006 18:18
 */

public class PayPresenter extends AppPresenter<AlipayView> {
    private BaseModel payModel = new PayModel();
    /**
     * View和Model通过Presenter进行交互
     */
    public void alipay() {
        payModel.alipayData(new BaseModel.aliypayOnListener() {
            @Override
            public void onstart(int resId) {
                getView().startPay(resId);
            }

            @Override
            public void onSucc(PayBean payBean) {
                getView().getPaySucc(payBean);
            }

            @Override
            public void onFail(String message) {
                getView().getPayFail(message);
            }
        });
    }

    public void wxPay() {
        payModel.wxPayData(new BaseModel.wxPayOnListener() {

            @Override
            public void onstart(int resId) {
                getView().startPay(resId);
            }

            @Override
            public void onSucc(WxPayBean payBean) {
                getView().getWxPaySucc(payBean);
            }

            @Override
            public void onFail(String message) {
                getView().getPayFail(message);
            }

        });
    }
}
